<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%
	request.setAttribute("ctx", request.getContextPath());
%>
<!doctype html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" href="${ctx}/css/login.css" />
	<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
	<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
	<title>三峡大学仁和医院追溯系统</title>
</head>
<body onkeydown="checkEnter(event)">
	<div id="container">
		<div id="bd">
			<div class="login">
            	<div class="login-top"><h1 class="logo"></h1></div>
                <div class="login-input">
                	<p class="user ue-clear">
                    	<label>用户名</label>
                        <input type="text" id="uname" name="uname" />
                    </p>
                    <p class="password ue-clear">
                    	<label>密&nbsp;码</label>
                        <input type="password" id="upass" name="upass"/>
                    </p>
                </div>
                <div class="login-btn ue-clear">
                	<a href="javascript:;" class="btn tologin">登录</a>
                	<div class="remember ue-clear">
                    	<input type="checkbox" id="remember" />
                        <em></em>
                        <label for="remember">记住密码</label>
                    </div>
                </div>
            </div>
		</div>
	</div>
	<div id="ft">CopyRight&nbsp;2016&nbsp;&nbsp;版权所有&nbsp;&nbsp;武汉雷软科技有限公司</div>

	<script type="text/javascript">
	
	
	
	var height = $(window).height();
	$("#container").height(height);
	$("#bd").css("padding-top",height/2 - $("#bd").height()/2);
	
	$(window).resize(function(){
		var height = $(window).height();
		$("#bd").css("padding-top",$(window).height()/2 - $("#bd").height()/2);
		$("#container").height(height);
		
	});
	
	$(function() {
		$(".tologin").click(function(){
			login();
		});
	});
	
	function login(){
		var uname = $("#uname").val();
		var upass = $("#upass").val();
		if($("#uname").val()=='' || $("#upass").val()==''){
			layer.msg("请输入用户名和密码");
			return false;
		}
		$.ajax({
	          url: "${ctx}/employee/login.do",
	          type: "POST",
	          dataType: "json",// 返回值类型
	          data:"username="+uname+"&password="+upass,
	          success: function(data) {
					if(data.status==false){
						 layer.msg(data.msg);
					}else{
						window.location.href='${ctx}/page/index.jsp';
					}
	          },
	          error: function() {
	        	  window.location.href='${ctx}/page/error/error.jsp';
	          }
	    });
	};
	
	function checkEnter(event){
		var key = window.event ? event.keyCode:event.which;
		if(key == 13){
			login();
		}
	}
	</script>
</body>
</html>